package com.rt.easyjava.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by wxy on 2017/9/6.
 */
public enum City {
    ShangHai(1, "上海", 0L),
    Baijin(2, "北京", 0L);

    private final Integer id;
    private final String name;
    private Long optionId;//选择指定的optionid后，隐藏哪些列

    City(Integer id, String name, Long optionId ) {
        this.id = id;
        this.name = name;
        this.optionId = optionId;
    }

    public static String explain(Integer id) {
        return explain(id, null) ;
    }

    public static String explain(Integer id, String unexpectedValue) {
        for (City enum1 : City.values()) {
            if (enum1.id.equals(id)) {
                return enum1.getName();
            }
        }
        return unexpectedValue;
    }

    public static List<Map<String,Object>> toList () {
        List <Map<String,Object>> list = new ArrayList();
        for (City enum1 : City.values()) {
            Map<String,Object> map = new HashMap();
            map.put("id", enum1.getId());
            map.put("name", enum1.getName());
            map.put("optionId", enum1.getOptionId());
            list.add(map);
        }
        return list;
    }

    public Integer getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public Long getOptionId() {
        return optionId;
    }

}
